#include "mtextbox.h"

#include <QPainter>

MTextBox::MTextBox(QString text, int w, int h, QGraphicsItem *parent) :
    QGraphicsWidget(parent), text(text), w(w), h(h)
{
    mouse_over = false;
}

void MTextBox::setMouseOver(bool b)
{
    mouse_over = b;
}

void MTextBox::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
    if (mouse_over)
    {
        QPen q;
        q.setWidth(4);
        p->setPen(q);
    }
    p->drawRect(0, 0, w, h);
    p->drawText(0, 0, w, h, Qt::AlignCenter | Qt::AlignHCenter, text);
}
